package com.drools.demo.server;

import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author czq
 * @Package com.drools.demo.server
 * @Date 2024/8/27 16:54
 * @description:
 */

@Service
public class List2Service {
    @Autowired
    private KieContainer kieContainer;
    public void executeRules(List<String> list, String item) {
        List<String> items= new ArrayList<>();
        items.add("1");
        items.add("2");
        KieSession kieSession = kieContainer.newKieSession();
        kieSession.getAgenda().getAgendaGroup("list_group2").setFocus();
        kieSession.setGlobal("itemList", list);
        kieSession.insert("1");
        kieSession.fireAllRules();
        kieSession.dispose();
    }
}
